

import  wx

#from  ideagen.UI import constants

class WinDict:
  
    class __Dict:
      
        def __init__(self):
            self.windows = {}
            pass
        
        def __str__(self):
            str = ""
            for key in self.windows:
                str += "%s:%s\n" %( key, self.windows[key])
            return str
        
        def set(self, key,value): #WriteText
            #print "set"
            if key in self.windows:
                print key,"exists"
            else:
                self.windows[key] = value
            
          #print text
        def get(self,key):
            #print "get"
            pass
            return self.windows[key]
        """
          if text[-1:] == '\n':
              text = text[:-1]
          cons = constants.Constants()
          textctrl = wx.FindWindowById(cons.LOG_TEXTCTRL)
          textctrl.AppendText(text+"\n")
        
          # write = WriteText  # why do this?  log.write
        """
    instance = None

    def __init__(self):
        if not WinDict.instance:
            WinDict.instance =WinDict.__Dict()            
        else:
            pass
    #print Log.instance

    def __getattr__(self, name):
        return getattr(self.instance, name)      


def test():
    log = WinDict()
    log.set('test','-1')
    alog = WinDict()
    alog.set('t2','100')
    alog.set('t200','1000')
    alog.set('t200','1001')
    print log.get('t200')

if __name__ == "__main__":
    test()
